package sqldemo.mybatis.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import sqldemo.mybatis.mapper.UsersMapper;
import sqldemo.mybatis.entity.Users;

import java.util.List;

@RestController
@RequestMapping("/mybatisSql")
public class UsersController {
    @Autowired
    private UsersMapper usersMapper;
    //orderby查询 http://localhost:8080/mybatisSql/orderby?sort=username
    @GetMapping("/orderby")
    public List<Users> orderbySql(@RequestParam("sort") String sort) {

        return usersMapper.orderbyInjection(sort);
    }
    //in查询 http://localhost:8080/mybatisSql/in?params=1
    @GetMapping("/in")
    public List<Users> inSql(@RequestParam("params") String params) {
        return usersMapper.inInjection(params);
    }
    //Like查询 http://localhost:8080/mybatisSql/like?username=admin
    @GetMapping("/like")
    @ResponseBody
    public List<Users> likeSql(@RequestParam("username") String username){
        return usersMapper.likeInjection(username);
    }
}
